#include <iostream>

using namespace std;

static int year_day = 365;
static int month_day[][13] = { 
  { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
  { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
};

class Date
{    
public:
  Date( int y, int m, int d ):year(y), month(m), day(d) { }
  ~Date() { }

public:
  int year;
  int month;
  int day;
};

int get_date_distance( Date& d1, Date& d2 )
{
  int sum_day = 0;
  int year1 = d1.year, year2 = d2.year;
  int flag1 = ( year1%4 == 0 && year1%100 != 0 ) || ( year1%400 == 0 );
  int flag2 = ( year2%4 == 0 && year2%100 != 0 ) || ( year2%400 == 0 );
  int day1 = month_day[flag1][d1.month] + d1.day;
  int day2 = month_day[flag2][d2.month] + d2.day;
  sum_day += (day2 - day1);

  int year_dec = year2 - year1;
  if( year_dec < 0 )
    return 0;
  sum_day += (year_day * year_dec);
  for( int y = year1; y < year2; y++ ){
    sum_day += ( ( y%4 == 0 && y%100 != 0 ) || ( y%400 == 0 ) );
  }
  
  return sum_day;
}

int get_week_day( Date& d )
{
  Date td(1990, 1, 1);
  int day_dis = get_date_distance( td, d );
  return 1 + (day_dis%7);
}

int main()
{
  Date d1(1997, 3, 12);
  Date d2(2009, 10, 26);

  cout << get_date_distance( d1, d2 ) << endl;
  cout << get_week_day( d2 ) << endl;
  
  return 0;
}
